<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 130px;
            height: 34px;
            float: left;
            margin: 10px 10px 0px 10px;
            background-image: url(../img/精灵图.jpg)
        }

        .box1 {
            background-color: royalblue;
        }

        .box2 {
            background-color: salmon;
            /*定位背景图的位置*/
            background-position: -130px 34px;
        }

        .box3 {
            background-color: springgreen;
        }
    </style>
</head>

<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
</body>

</html>